package com.heima.comment.controller.v1;

import com.heima.comment.service.ICommentService;
import com.heima.model.comment.dtos.CommentLikeDTO;
import com.heima.model.comment.dtos.CommentQueryDTO;
import com.heima.model.comment.dtos.CommentSaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "文章评论 API")
@RestController
@RequestMapping("api/v1/comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @ApiOperation(value = "文章下发表评论", notes = "文章下发表评论")
    @PostMapping("save")
    public ResponseResult saveComment(@RequestBody @Validated CommentSaveDTO commentSaveDTO){
        return commentService.saveComment(commentSaveDTO);
    }

    @ApiOperation(value = "文章下评论点赞", notes = "文章下评论点赞")
    @PostMapping("like")
    public ResponseResult handleLike(@RequestBody @Validated CommentLikeDTO commentLikeDTO){
        return commentService.handleLike(commentLikeDTO);
    }

    @ApiOperation(value = "查询文章评论列表", notes = "查询文章评论列表")
    @PostMapping("load")
    public ResponseResult listComment(@RequestBody @Validated CommentQueryDTO commentQueryDTO){
        return commentService.listComment(commentQueryDTO);
    }
}
